//
//  ListTableViewCell.m
//  MXClassroom
//
//  Created by 你个LB on 16/9/9.
//  Copyright © 2016年 你个LB. All rights reserved.
//

#import "ListTableViewCell.h"

@implementation ListTableViewCell

/** 初始化方法 */
+ (instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString * reuseIdentifier = @"identifier";
    ListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
    if (cell == nil) {
        // 创建cell
        cell = [[ListTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 图标
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(8, 4, 120, 67)];
        [self.contentView addSubview:_imageView];
        
        // 介绍
        _introductionLabel = [[UILabel alloc] initWithFrame:CGRectMake(_imageView.right + 16, 4, kScreen_width - _imageView.width - 2 * 16, 25)];
        _introductionLabel.textColor = kColor_text_color;
        _introductionLabel.font = [UIFont systemFontOfSize:10];
        _introductionLabel.numberOfLines = 0;
        [self.contentView addSubview:_introductionLabel];
        
        // 法师姓名前面的小图标
        UIImageView * person_icon = [[UIImageView alloc] initWithFrame:CGRectMake(_imageView.right + 16, 0, 14, 14)];
        person_icon.image = [UIImage imageNamed:@"人员头像28px.png"];
        person_icon.bottom = _imageView.bottom;
        [self.contentView addSubview:person_icon];
        
        // 法师姓名
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(person_icon.right + 7, 0, 100, 14)];
        _nameLabel.bottom = person_icon.bottom;
        _nameLabel.textColor = kColor_text_color;
        _nameLabel.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:_nameLabel];
        
        // 收听人数
        _person_NumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(kScreen_width - 100 - 17, 16, 100, 15)];
        _person_NumberLabel.bottom = _nameLabel.bottom;
        _person_NumberLabel.textColor = kColor_text_color;
        _person_NumberLabel.font = [UIFont systemFontOfSize:10];
        _person_NumberLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_person_NumberLabel];
    }
    return self;
}

- (void)setList:(ListModel *)list{
    if (_list != list) {
        _list = list;
        
        // 为控件设置数据
        _imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", list.imageName]];
        
        _introductionLabel.text = list.introduction;
        
        _nameLabel.text = list.name;
        
        _person_NumberLabel.text = [NSString stringWithFormat:@"%@人在收听",list.person_Number];
    }
}

@end
